#include "ImageDisplay.h"
#include "../../../src/ImageBitConver.h"

Image8BitConver conver;

ImageDisplay::ImageDisplay(wxWindow* parent) :
    wxPanel(parent,wxID_ANY)
{
    oImage.Create(10,10);
    Bind(wxEVT_PAINT,&ImageDisplay::OnPaint,this,wxID_ANY);
}

void ImageDisplay::OnPaint(wxPaintEvent& event)
{
    wxPaintDC dc(this);
    wxSize size=GetClientSize();
    dc.DrawBitmap(oImage.Scale(size.GetWidth(),size.GetHeight()),0,0);
}

void ImageDisplay::showImage(unsigned char* image,int height,int width,pixelFormat format)
{
  unsigned char* rawData;
    switch(format)
    {
      case pixelFormat::MONO8:
        rawData=conver.HandleImage(image,height*width);
        break;
      case pixelFormat::BAYER_RG8:
        rawData=conver.HandleBayerImage(image,width,height);
        break;
      default:
        break;
    }
    oImage.SetData(rawData,width,height,false);
    Refresh(false);
    delete [] image;
}
